package com.aaron.book.thinkinginjava.c21.p656;

public class C21E1 {

    public static void main(String[] args) {

        for (int i = 0; i < 100; i++) {
            new Thread(new Printer()).start();
        }

    }

}

class Printer implements Runnable{

    private static int taskCount = 0;

    private final int id = taskCount++;

    public Printer() {
        System.out.println("Printer"+id+"is starting up!");
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.println("Printer" + id + " printing for the " + (i + 1) + "th time");
            Thread.yield();
        }

        System.out.println("End of printing");
    }

}
